package com.pstreets.lwuit.demo.widgets;


import com.sun.lwuit.Command;
import com.sun.lwuit.Component;
import com.sun.lwuit.Display;
import com.sun.lwuit.Form;
import com.sun.lwuit.Image;
import com.sun.lwuit.Label;
import com.sun.lwuit.animations.CommonTransitions;
import com.sun.lwuit.layouts.BoxLayout;
import com.sun.lwuit.plaf.UIManager;
import com.sun.lwuit.util.Resources;
import java.io.IOException;
import javax.microedition.midlet.MIDlet;

/**
 * @author james
 */
public class TickeringDemo extends MIDlet {

    public void startApp() {
        
        //init the LWUIT display
        Display.init(this);
        
        //setting the application theme
        try{
            Resources r=Resources.open("/LWUITtheme.res");
            UIManager.getInstance()
                    .setThemeProps(r.getTheme
                    (r.getThemeResourceNames()[0]));
        }catch (Exception e){}
        
        Form mainForm = new Form("Tickering Demo");
        mainForm.setLayout(new BoxLayout(BoxLayout.Y_AXIS));
        Label label1=new Label("Text Only Label, "
                + "and I am a really long long text");
        label1.startTicker(100, true);
        mainForm.addComponent(label1);
        try {
            Image icon = Image.createImage("/navigator.png");
            Label label2=new Label(icon);
            mainForm.addComponent(label2);
            

            Label label3=new Label(icon);
            label3.setText("Image and Text Label,"
                    + " and I am a really long long text");
            mainForm.addComponent(label3);
            label3.startTicker(300, false);
            Label label4=new Label(icon);
            label4.setText("Image and Text Label at Bottom, "
                    + "and I am a really long long text");
            label4.setTextPosition(Component.BOTTOM);
            label4.startTicker(100, true);
            mainForm.addComponent(label4);
        } catch (IOException ex) {
            ex.printStackTrace();
        }
        
        

        mainForm.setTransitionOutAnimator(CommonTransitions.createFade(400));
        mainForm.addCommand(new Command("Left soft key", 2));
        mainForm.addCommand(new Command("Right Soft key", 2));
        mainForm.show();
        
    
    }
    
    public void pauseApp() {
    }
    
    public void destroyApp(boolean unconditional) {
    }
}
